package spring.boot.server.common;

import io.netty.channel.Channel;
import io.netty.channel.ChannelId;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;

import java.util.HashMap;
import java.util.Map;

/**
 * 常量
 */
public final class NettyServerConstant {

    /**
     * 服务端 port
     */
    public static final int SERVER_PORT = 7777;

    /**
     * boss 线程组，用于服务端接受客户端的连接
     */
    public static final EventLoopGroup BOSS_GROUP = new NioEventLoopGroup(1);

    /**
     * worker 线程组，用于服务端接受客户端的数据读写
     */
    public static final EventLoopGroup WORKER_GROUP = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors() * 2);

    /**
     * Netty Server Channel
     */
    public static Channel CHANNEL;

    public static final Map<ChannelId, Integer> HEART_BEAT_MAP = new HashMap<>();

    public static final String TOKEN_SECRET = "TD8QKZ3Ah1YVLrS1Rrg9QzdQlhTpVvoP";

}
